/**
 * 
 */
package com.acminds.fotoporter.ui.controllers;

import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;

import com.acminds.fotoporter.persistence.dto.Client;
import com.acminds.fotoporter.persistence.dto.Location;
import com.acminds.fotoporter.service.client.ClientService;
import com.acminds.fotoporter.ui.BaseAction;

/**
 * @author MANSUR
 *
 */
@ManagedBean
@RequestScoped
public class ClientAction extends BaseAction {
	
	@ManagedProperty(value="#{clientService}")
	private ClientService clientService;
	@ManagedProperty(value="#{client}")
	private Client client;
	
	public ClientService getClientService() {
		return clientService;
	}
	public void setClientService(ClientService clientService) {
		this.clientService = clientService;
	}
	public Client getClient() {
		return client;
	}
	public void setClient(Client client) {
		this.client = client;
	}
	
	public String addClient() {
		client.setLocations(new ArrayList<Location>());
		Location location = new Location();
		location.setLocationType(0);
		client.getLocations().add(new Location());
		return null;
	}
	
	public String saveClient() {
		getClientService().saveClient(client);
		return null;
	}
}
